'\" te
.\" Copyright (c) 2005, Sun Microsystems, Inc.  All Rights Reserved.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH GETUSERATTR 3SECDB "Aug 13, 2018"
.SH NAME
getuserattr, getusernam, getuseruid, free_userattr, setuserattr, enduserattr,
fgetuserattr \- get user_attr entry
.SH SYNOPSIS
.LP
.nf
cc [ \fIflag\fR... ] \fIfile\fR... -lsecdb  -lsocket  -lnsl [ \fIlibrary\fR... ]
#include <user_attr.h>

\fBuserattr_t *\fR\fBgetuserattr\fR(\fBvoid\fR);
.fi

.LP
.nf
\fBuserattr_t *\fR\fBgetusernam\fR(\fBconst char *\fR\fI\fR\fIname\fR);
.fi

.LP
.nf
\fBuserattr_t *\fR\fBgetuseruid\fR(\fBuid_t\fR \fIuid\fR);
.fi

.LP
.nf
\fBvoid\fR \fBfree_userattr\fR(\fBuserattr_t *\fR\fIuserattr\fR);
.fi

.LP
.nf
\fBvoid\fR \fBsetuserattr\fR(\fBvoid\fR);
.fi

.LP
.nf
\fBvoid\fR \fBenduserattr\fR(\fBvoid\fR);
.fi

.LP
.nf
\fBuserattr_t *\fR\fBfgetuserattr\fR(\fBFILE *\fR\fIf\fR);
.fi

.SH DESCRIPTION
.LP
The \fBgetuserattr()\fR, \fBgetusernam()\fR, and \fBgetuseruid()\fR functions
each return a \fBuser_attr\fR(5) entry. Entries can come from any of the
sources specified in the \fBnsswitch.conf\fR(5) file. The \fBgetuserattr()\fR
function enumerates \fBuser_attr\fR entries. The \fBgetusernam()\fR function
searches for a \fBuser_attr\fR entry with a given user name \fIname\fR. The
\fBgetuseruid()\fR function searches for a \fBuser_attr\fR entry with a given
user ID \fIuid\fR. Successive calls to these functions return either successive
\fBuser_attr\fR entries or \fINULL\fR.
.sp
.LP
The \fBfgetuserattr()\fR function does not use \fBnsswitch.conf\fR but reads
and parses the next line from the stream \fIf\fR. This stream is assumed to
have the format of the \fBuser_attr\fR files.
.sp
.LP
The \fBfree_userattr()\fR function releases memory allocated by the
\fBgetusernam()\fR, \fBgetuserattr()\fR, and \fBfgetuserattr()\fR functions.
.sp
.LP
The internal representation of a \fBuser_attr\fR entry is a \fBuserattr_t\fR
structure defined in <\fBuser_attr.h\fR> with the following members:
.sp
.in +2
.nf
char  *name;       /* name of the user */
char  *qualifier;  /* reserved for future use */
char  *res1;       /* reserved for future use */
char  *res2;       /* reserved for future use */
kva_t *attr;       /* list of attributes */
.fi
.in -2

.sp
.LP
The \fBsetuserattr()\fR function "rewinds" to the beginning of the enumeration
of \fBuser_attr\fR entries.  Calls to \fBgetusernam()\fR may leave the
enumeration in an indeterminate state, so \fBsetuserattr()\fR should be called
before the first call to \fBgetuserattr()\fR.
.sp
.LP
The \fBenduserattr()\fR function may be called to indicate that \fBuser_attr\fR
processing is complete; the library may then close any open \fBuser_attr\fR
file, deallocate any internal storage, and so forth.
.SH RETURN VALUES
.LP
The \fBgetuserattr()\fR function returns a pointer to a \fBuserattr_t\fR if it
successfully enumerates an entry; otherwise it returns \fINULL\fR, indicating
the end of the enumeration.
.sp
.LP
The \fBgetusernam()\fR function returns a pointer to a \fBuserattr_t\fR if it
successfully locates the requested entry; otherwise it returns \fINULL\fR.
.SH USAGE
.LP
The \fBgetuserattr()\fR and \fBgetusernam()\fR functions both allocate memory
for the pointers they return. This memory should be deallocated with the
\fBfree_userattr()\fR function.
.sp
.LP
Individual attributes can be referenced in the \fBattr\fR structure by calling
the \fBkva_match\fR(3SECDB) function.
.SH WARNINGS
.LP
Because the list of legal keys is likely to expand, code must be written to
ignore unknown key-value pairs without error.
.SH FILES
.ne 2
.na
\fB\fB/etc/user_attr\fR\fR
.ad
.RS 22n
extended user attributes
.RE

.sp
.ne 2
.na
\fB\fB/etc/nsswitch.conf\fR\fR
.ad
.RS 22n
configuration file lookup information for the name service switch
.RE

.SH ATTRIBUTES
.LP
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
MT-Level	MT-Safe
.TE

.SH SEE ALSO
.LP
.BR getauthattr (3SECDB),
.BR getexecattr (3SECDB),
.BR getprofattr (3SECDB),
.BR kva_match (3SECDB),
.BR user_attr (5),
.BR attributes (7)
